/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ru.rantipin.persistence;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author rantipin
 */
@Entity
@Table(name = "photo")
@NamedQueries({@NamedQuery(name = "Photo.findAll", query = "SELECT p FROM Photo p"), @NamedQuery(name = "Photo.findById", query = "SELECT p FROM Photo p WHERE p.id = :id"), @NamedQuery(name = "Photo.findByName", query = "SELECT p FROM Photo p WHERE p.name = :name"), @NamedQuery(name = "Photo.findByPercentBlack", query = "SELECT p FROM Photo p WHERE p.percentBlack = :percentBlack"), @NamedQuery(name = "Photo.findByDescription", query = "SELECT p FROM Photo p WHERE p.description = :description")})
public class Photo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Column(name = "name")
    private String name;
    @Column(name = "percent_black")
    private Double percentBlack;
    @Column(name = "description")
    private String description;
    @Lob
    @Column(name = "photo_real")
    private byte[] photoReal;
    @Lob
    @Column(name = "photo_processing")
    private byte[] photoProcessing;
    @OneToMany(mappedBy = "idPhoto", fetch = FetchType.LAZY)
    private Collection<Point> pointCollection;
    @JoinColumn(name = "id_sample", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Sample idSample;

    public Photo() {
    }

    public Photo(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getPercentBlack() {
        return percentBlack;
    }

    public void setPercentBlack(Double percentBlack) {
        this.percentBlack = percentBlack;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public byte[] getPhotoReal() {
        return photoReal;
    }

    public void setPhotoReal(byte[] photoReal) {
        this.photoReal = photoReal;
    }

    public byte[] getPhotoProcessing() {
        return photoProcessing;
    }

    public void setPhotoProcessing(byte[] photoProcessing) {
        this.photoProcessing = photoProcessing;
    }

    public Collection<Point> getPointCollection() {
        return pointCollection;
    }

    public void setPointCollection(Collection<Point> pointCollection) {
        this.pointCollection = pointCollection;
    }

    public Sample getIdSample() {
        return idSample;
    }

    public void setIdSample(Sample idSample) {
        this.idSample = idSample;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Photo)) {
            return false;
        }
        Photo other = (Photo) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ru.rantipin.persistence.Photo[id=" + id + "]";
    }

}
